package com.quectel.core.module.parkingcard.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.quectel.core.module.parkingcard.entity.ParkingCardMemberDeviceEntity;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * @author ryan
 * @email ryan.ran@quectel.com
 * @date 2023/04/24 15:24
 */

public interface ParkingCardMemberDeviceDao extends BaseMapper<ParkingCardMemberDeviceEntity> {

    /**
     * 查询列表
     *
     * @param params
     * @return
     */
    List<ParkingCardMemberDeviceEntity> queryList(Map<String, Object> params);

    /**
     * 查询数量
     *
     * @param params
     * @return
     */
    int queryTotal(Map<String, Object> params);

    @Select("<script>select pcmd.*, d.name as device_name from (select * from parking_card_member_device where parking_card_member_id = #{memberId}) pcmd LEFT JOIN device d on pcmd.device_id = d.id" +
            "</script>")
    List<ParkingCardMemberDeviceEntity> selectByMemberId(@Param("memberId") Long memberId);
}
